const Wechat = require('../util/Wechat'),
  log = require('../util/log')

module.exports = (req, res) => {
  require('../util/service').handlePost(req, res, (reqObj, resolve) => {
    var wechat = Wechat({
      AppID: 'wxae9c0d778b917c56',
      AppSecret: 'fd68e9e7d03cdd3ff105552594b05b8b'
    })
    wechat.gettoken().then(result => {
      wechat.cardCodeDecrypt(reqObj).then(result => {
        resolve(result)
      }, result => {
        log(result)
        resolve({
          result: -1,
          msg: result
        })
      })
    })
  })
}
